import torch


def make_causal_attention_mask(
    seq_len: int, *,
    dtype: torch.dtype | str | None = torch.bool,
    device: torch.device | str | None = None
) -> torch.Tensor:
    """ make causal mask for self-attention

    :return: mask
        shape=[seq_len (query), seq_len (key)]
    """
    mask = torch.ones([seq_len, seq_len], dtype=dtype, device=device)
    mask = torch.triu(mask, diagonal=0)
    mask = torch.transpose(mask, 0, 1)
    return mask
